home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / jaz_clib.arc / JZPOPDIR.C < prev    next >
Text File  |  1989-04-09  |  1KB  |  38 lines

  1. #include <jaz.h>
  2.  
  3. /*
  4. ┌────────────────────────────────────────────────────────────────────────────┐
  5. │jzpopdir                                     │
  6. │Pop the directory off the directory stack and change back to that directory │
  7. │Notes                                         │
  8. │  if fpopdrive is NON zero, the drive will be popped also.             │
  9. │Synopsis                                     │
  10. │   pushdir(&whead);                                 │
  11. │   chdir("\\test");                                                         │
  12. │   ....                                     │
  13. │   jzpopdir(&whead,1);   (pop the directory and drive)              │
  14. └────────────────────────────────────────────────────────────────────────────┘
  15. */
  16.  
  17. jzpopdir(fhead,fpopdrive)
  18. TSTKHEAD *fhead;
  19. int fpopdrive;            /* non zero if we should pop the drive */
  20. {
  21.   TSTACK *wtemp;
  22.  
  23.   if (fhead->numitems) {    /* don't pop anything if there is no stack */
  24.     chdir(fhead->last->pointer);    /* restore the path */
  25.     if (fpopdrive)
  26.       jzlogdrv(fhead->last->wint);    /* get original drive back */
  27.  
  28.     wtemp = fhead->last;        /* save temp copy of pointer */
  29.  
  30.     fhead->last = fhead->last->prev;
  31.     fhead->numitems --;         /* decrement count of items */
  32.  
  33.     free(wtemp->pointer);           /* free memory for path */
  34.     free((char *) wtemp);
  35.  
  36.   }
  37. }
  38.